<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
<body>
<div id="myApp">
    姓 <input v-model="firstName">
    名<input v-model="lastName">
    <p v-text="fullName"></p>
    <p v-text="count"></p>
</div>
</body>
<script>
    new Vue({
        el: "#myApp",
        data: {
            firstName: '',
            lastName: '',
            count: 0
        }, computed: {
            // 计算属性，computed  第二次计算时 如果firstName和lastName的值没有改变，fullName会自动去去缓存中的值
            fullName: function () {
                return this.firstName + this.lastName;
            }
        }, watch: {
            // 通过watch 来监听 fullName的变化。
            fullName: function () {
                this.count++;
            }
        }
    })
</script>
</html>